import java.io.*;
import java.util.*;

/**
 * @author Patrick Bartylla
 * @version 1
 * @Date 21.05.2013
 */
public class DataManager {

	//----------------------------------------------------------------------------------------------------------------------------------------------------
	private static DataManager instance = null;

	/**
	 * Default Constructor
	 */
	private DataManager()
	{
	}

	/**
	 * Returns the Instance of the Data Manager
	 * @return
	 */
	public static DataManager getDataManagerInstance()
	{
		if(DataManager.instance == null)
			instance = new DataManager();
		return DataManager.instance;
	}


	//----------------------------------------------------------------------------------------------------------------------------------------------------
	/*
	 *  Paths 
	 */
	private File projectDirectory = null;
	private File referenceDirectory = null;
	private File trainDataDirectory = null;
	private File outputDataDirectory = null;
	private File mainDataDirectory = null;
	private File questionsDataDirectory = null;
	
	/**
	 * Returns the Project Directory
	 * @return ProjectPath
	 */
	public File getProjectDirectory(){	   
		if(projectDirectory == null)
		{
			projectDirectory = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
		}
		return projectDirectory;
	}



	/**
	 * Returns the Reference Directory
	 * @return referencePath
	 */
	public File getReferencePath(){	   
		if(referenceDirectory == null)
		{
			referenceDirectory = new File(instance.getProjectDirectory(), "Recources");
		}
		return referenceDirectory;
	}


	/**
	 * Returns the TrainData Path
	 * @return trainDataDirectory
	 */
	public File getTrainDataDirectory(){	   
		if(trainDataDirectory == null)
		{
			trainDataDirectory = new File(instance.getReferencePath(), trainPackage);
		}
		return trainDataDirectory;
	}


	/**
	 * Returns the Output Path
	 * @return outputDataDirectory
	 */
	public File getOutputDataDirectory(){	   
		if(outputDataDirectory == null)
		{
			outputDataDirectory = new File(instance.getReferencePath(), outputPackage);
		}
		return outputDataDirectory;
	}


	/**
	 * Returns the mainData Path
	 * @return mainDataDirectory
	 */
	public File getMainDataDirectory(){	   
		if(mainDataDirectory == null)
		{
			mainDataDirectory = new File(instance.getReferencePath(), mainPackage);
		}
		return mainDataDirectory;
	}


	/**
	 * Returns the Question Directory
	 * @return questionsDataDirectory
	 */
	public File getQuestionDirectory(){	   
		if(questionsDataDirectory == null)
		{
			questionsDataDirectory = new File(instance.getReferencePath(), questionPackage);
		}
		return questionsDataDirectory;
	}
	
	//----------------------------------------------------------------------------------------------------------------------------------------------------
	/* 
	 * Packages 
	 */
	private final String outputPackage = "Output";
	private final String mainPackage = "MainData";
	private final String trainPackage = "TrainData";
	private final String questionPackage = "Questions";


	/**
	 * Returns the Output Data Package Name
	 * @return learnPackage
	 */
	public String getLearnPackage() {
		return outputPackage;
	}

	/**
	 * Returns the Main Data Package Name
	 * @return mainPackage
	 */
	public String getMainPackage() {
		return mainPackage;
	}

	/**
	 * Returns the Train Data Package Name
	 * @return trainPackage
	 */
	public String getTrainPackage() {
		return trainPackage;
	}
	
	/**
	 * Returns the Train Data Package Name
	 * @return questionPackage
	 */
	public String getQuestionPackage() {
		return questionPackage;
	}


	//----------------------------------------------------------------------------------------------------------------------------------------------------
	/*
	 *  Feature Vector 
	 */
	private final String featureVectorFileName = "FV.txt";
	private final String featureVectorAcronym = "FV";
	private ArrayList<String> featureWords = null;

	/**
	 * Returns all words of the FeatureVector
	 * @return featureWords
	 */
	public ArrayList<String> getFeatureWords() {
		return featureWords;
	}

	/**
	 * Sets new words to the Feature Vector
	 * @param featureWords
	 */
	public void setFeatureWords(ArrayList<String> featureWords) {
		this.featureWords = featureWords;
	}

	/**
	 * Returns the Feature Vector File Name
	 * @return featureVectorName
	 */
	public String getFeatureVectorFileName() {
		return featureVectorFileName;
	}

	/**
	 * Returns the Feature Vector Acronym
	 * @return featureVectorAcronym
	 */
	public String getFeatureVectorAcronym() {
		return featureVectorAcronym;
	}


	//----------------------------------------------------------------------------------------------------------------------------------------------------
	/* 
	 * Classes 
	 */
	private final String classFileName = "Classes.txt";
	private final String classAcronym = "Classes";
	private ArrayList<String> allClasses = null;
	private int classesCount = 0;

	
	/**
	 * Returns the count of the classes
	 * @return classesCount
	 */
	public int getClassesCount() {
		return classesCount;
	}

	/**
	 * Sets the count of the classes
	 * @param classesCount
	 */
	public void setClassesCount(int classesCount) {
		this.classesCount = classesCount;
	}

	/**
	 * Returns an array of all Classes
	 * @return allClasses
	 */
	public ArrayList<String> getAllClasses() {
		return allClasses;
	}

	/**
	 * Set an array of all Classes
	 */
	public void setAllClasses(ArrayList<String> Classes) {
		allClasses = Classes;
	}
	
	/**
	 * Returns the Class File Name
	 * @return classFileName
	 */
	public String getClassFileName() {
		return classFileName;
	}

	/**
	 * Returns the Class Acronym
	 * @return classAcronym
	 */
	public String getClassAcronym() {
		return classAcronym;
	}


	//----------------------------------------------------------------------------------------------------------------------------------------------------
	/* 
	 * ARFF 
	 */
	private final String ARFFFileName = "ARFF.txt";
	private final String ARFFAcronym = "ARFF";
	private ArrayList<ArrayList<Integer>> ARFFdata = null;
	private ArrayList<String>  ARFFRowClass	 = new ArrayList<String>();
	
	
	/**
	 * Returns a list of "ARFF Row Class"
	 * @return ARFFRowClass
	 */
	public ArrayList<String> getARFFRowClass()
	{
		return ARFFRowClass;
	}
	
	/**
	 * Sets a list of "ARFF Row Class"
	 * @param ARFFRowClass
	 */
	public void setARFFRowClass(ArrayList<String> ARFFRowClass)
	{
		this.ARFFRowClass = ARFFRowClass;
	}
	
	/**
	 * Returns the ARFFdata
	 * @return ARFFdata
	 */
	public ArrayList<ArrayList<Integer>> getARFFdata() {
		return ARFFdata;
	}
	
	/**
	 * Sets the ARFFdata
	 * @param ARFFdata
	 */
	public void setARFFdata(ArrayList<ArrayList<Integer>> ARFFdata) {
		this.ARFFdata = ARFFdata;
	}
	

	/**
	 * Returns the ARFF File Name
	 * An Object is expected: ArrayList<String>
	 * @return ARFFFileName
	 */
	public String getARFFFileName() {
		return ARFFFileName;
	}

	/**
	 * Returns the ARFF Acronym
	 * @return ARFFAcronym
	 */
	public String getARFFAcronym() {
		return ARFFAcronym;
	}
	
	//----------------------------------------------------------------------------------------------------------------------------------------------------
	/* 
	 * NOISEDEU 
	 */
	private final String NoiseDeuFileName = "NOISEDEU.TXT";
	private ArrayList<String> NoiseDeudata = null;
	
	
	/**
	 * Returns a list of "NoiseDeudata"
	 * @return NoiseDeudata
	 */
	public ArrayList<String> getNoiseDeudata()
	{
		return NoiseDeudata;
	}
	
	public void setNoiseDeudata(ArrayList<String> NoiseDeudata)
	{
		this.NoiseDeudata = NoiseDeudata;
	}
	
	public String getNoiseFileName()
	{
		return this.NoiseDeuFileName;
	}
	
	
	//----------------------------------------------------------------------------------------------------------------------------------------------------
	/* 
	 * QuestionARFF 
	 */
	private final String QuestionARFFFileName = "QUESTION_ARFF.txt";
	private ArrayList<ArrayList<Integer>> QuestionARFFdata = null;
	private ArrayList<String>  QuestionARFFRowClass	 = new ArrayList<String>();
	
	
	/**
	 * Returns a list of "ARFF Row Class"
	 * @return ARFFRowClass
	 */
	public ArrayList<String> getQuestionARFFRowClass()
	{
		return QuestionARFFRowClass;
	}
	
	/**
	 * Sets a list of "ARFF Row Class"
	 * @param ARFFRowClass
	 */
	public void setQuestionARFFRowClass(ArrayList<String> QuestionARFFRowClass)
	{
		this.QuestionARFFRowClass = QuestionARFFRowClass;
	}	
	/**
	 * Returns the ARFFdata
	 * @return ARFFdata
	 */
	public ArrayList<ArrayList<Integer>> getQuestionARFFdata() {
		return QuestionARFFdata;
	}
	
	/**
	 * Sets the ARFFdata
	 * @param ARFFdata
	 */
	public void setQuestionARFFdata(ArrayList<ArrayList<Integer>> ARFFdata) {
		this.QuestionARFFdata = ARFFdata;
	}
	

	/**
	 * Returns the ARFF File Name
	 * An Object is expected: ArrayList<String>
	 * @return ARFFFileName
	 */
	public String getQuestionARFFFileName() {
		return QuestionARFFFileName;
	}
}
